<?PHP

session_start();
if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {
    header("Location: login.php");
}
//
include 'i_functions.php';
include 'i_csv2SQL.php';
//

$uname = "";
$pword = "";
$errorMessage = "";
$num_rows = 0;
$used = "";
//
$user_name = "root";
$pass_word = "haddons";
$database = "PPI";
$server = "127.0.0.1";
//
$db_handle = mysql_connect($server, $user_name, $pass_word);
$db_found = mysql_select_db($database, $db_handle);
//
if ($db_found) {
    $Options = "";
    $QHTML = BuildForm("ImportDataQ.csv", $db_handle, $Options);
} else {
    $errorMessage = "Database Not Found";
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
//
    $fields = $_POST['field'];
    $MapID = $fields[0];
    $MapRec = array();
    $Data = array();
    $c = "";
    $_SESSION['Work'] = array();
    $UE_Opts['Exit'] = "A";
    $UE_Func = $MapID;
    $UE_Code = $MapID . ".php";
    if (is_file($UE_Code)) {
        include $UE_Code;
        $Val = $UE_Func($MapRec, $Data, $c, $UE_Opts);
    } else {
        //
    }
    $SQL2 = csv2SQL_init($MapID);
    $MapRec = $SQL2[0];
    print "<br>" . $SQL2[1];
    $dlim = ",";
    $Data = explode(",", "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,ab,ac,ad,af,ag,ah,ai,aj,ak,al,am,an,ao,ap,aq,ar,as,at,au");
    $_SESSION['Work'] = array();
    $SQL2_Vals = csv2SQL_vals($MapID, $MapRec, $dlim, $Data);
    print "<br>" . $SQL2_Vals;
    //print "<br> MapID = " . $MapID;
} else {
    include 'i_head.php';
    include 'i_ImportForm.php';
    include 'i_foot.html';
}
?>


